Product
Introducing Ruby Support in Socket
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
is-core-module
Advanced tools
The is-core-module package is a simple utility that allows developers to check if a given module name corresponds to a Node.js core module. Core modules are modules that are included with Node.js itself, such as 'http', 'fs', and 'path'. This package is particularly useful when building tools that need to differentiate between core modules and third-party modules.
Check if a module is a core module
This feature allows you to check if a string corresponds to a Node.js core module. It returns true if the module is a core module, and false otherwise.
const isCoreModule = require('is-core-module');
console.log(isCoreModule('fs')); // true
console.log(isCoreModule('express')); // false
Check if a module is a core module with a specific Node.js version
This feature allows you to check if a module is a core module in a specific version of Node.js. This is useful when dealing with different Node.js versions that may have different sets of core modules.
const isCoreModule = require('is-core-module');
console.log(isCoreModule('fs', { version: '8.0.0' })); // true
console.log(isCoreModule('http2', { version: '8.0.0' })); // false
The builtin-modules package provides a list of the Node.js built-in modules. It is similar to is-core-module in that it helps identify core modules, but instead of checking a module name, it provides the full list of built-in modules for direct use.
The resolve package is a more complex module resolution library that can be used to resolve the path of a module like require.resolve does. It can also be used to check if a module is a core module by resolving its path and checking if it is null, which would indicate a core module. It offers more features than is-core-module but can be used for a similar purpose in some cases.
Is this specifier a node.js core module? Optionally provide a node version to check; defaults to the current node version.
var isCore = require('is-core-module');
var assert = require('assert');
assert(isCore('fs'));
assert(!isCore('butts'));
Clone the repo, npm install
, and run npm test
FAQs
Is this specifier a node.js core module?
The npm package is-core-module receives a total of 49,786,495 weekly downloads. As such, is-core-module popularity was classified as popular.
We found that is-core-module demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.